// pages/03/11.js
var httpUtil = require("../../../common/httpUtil.js");
const app = getApp
Page({

     /**
      * 页面的初始数据
      */
     data: {
          userInfo: "",
          uid: "",
          user: "",
          count:0,
          


     },
     navtomessage: function () {
          var that = this
          that.data.count = 0
          wx.removeTabBarBadge({
               index: 3,
          })
     },
     toUserInfoPage: function () {
          var that = this;
          var url = '/pages/User/MyHome/personaldata/personaldata?id=' + that.data.uid;
          wx.navigateTo({
               url: url,
          })

     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {

     },

     /**
      * 生命周期函数--监听页面初次渲染完成
      */
     onReady: function () {

     },

     /**
      * 生命周期函数--监听页面显示
      */
     onShow: function () {
          var that = this
          that.setData({
               p: 1
          })
          var uid = wx.getStorageSync('uid')
          // httpUtil.getWeiReadMessages(uid, function (data) {
          //      var count = data.data;

          //      console.log("data.data");
          //      console.log(data);
          //      that.setData({
          //           count: count
          //      });

          //      if (that.data.count > 0) {
          //           var num = that.data.count.toString() //将数字转换成字符串
          //           wx.setTabBarBadge({
          //                index: 4,
          //                text: num,
          //           })
          //      } else {
          //           wx.removeTabBarBadge({
          //                index: 3,
          //           })
          //      }
          // });
          var userInfo = wx.getStorageSync('userInfo');
          var uid = wx.getStorageSync('uid');
          var that = this;
          that.setData({
               userInfo: userInfo,

               uid: uid,
          });
          if (!uid) {
               console.log("未登录");
               return;
          }
          // httpUtil.getUser({
          //      uid: uid
          // }, function (data) {
          //      if (data.code === 200) {
          //           that.setData({
          //                user: data.data,
          //                avatarlength: data.data.avatar.length
          //           });


               //      console.log('uuuuuuuuuu', that.data.user)
               //      console.log('33333', that.data.user.avatar.length)



               // } else {
               //      console.log(data.message);
               // }
          // });

     },

     /**
      * 生命周期函数--监听页面隐藏
      */
     onHide: function () {

     },

     /**
      * 生命周期函数--监听页面卸载
      */
     onUnload: function () {

     },

     /**
      * 页面相关事件处理函数--监听用户下拉动作
      */
     onPullDownRefresh: function () {

     },

     /**
      * 页面上拉触底事件的处理函数
      */
     onReachBottom: function () {

     },

     /**
      * 用户点击右上角分享
      */
     onShareAppMessage: function () {

     }
})